#include <fstream>
#include <iostream>
using namespace std;
#define max_N 100
#define max_M 100
char tile[max_N][max_M];
int N = 0;
int M = 0;
int result = 0;
void dfs(int nx,int ny){
    if (nx >= 0 && nx < N && ny >= 0&& ny<M&&tile[nx][ny]!='#') {
        tile[nx][ny] = '#';
        result += 1;
        dfs(nx - 1, ny);
        dfs(nx + 1, ny);
        dfs(nx, ny - 1);
        dfs(nx, ny + 1);
    }

}
int main()
{
    //fstream cin("test.txt");
    while(cin>>M>>N){
        if (N==0||M==0)
            break;
        int nx = 0;
        int ny = 0;
        result = 0;
        for (int i = 0; i < N;++i)
            for (int j = 0; j < M;++j){
                cin >> tile[i][j];
                if (tile[i][j] == '@'){
                    nx = i;
                    ny = j;
                }
            }
        dfs(nx, ny);
        cout << result<<endl;
    }
    return 0;
}